package com.hyts.network.client;


import com.hyts.network.base.ClientFactoryBean;
import com.hyts.network.config.DefaultNetwork;

import java.io.IOException;
import java.net.Socket;

/**
 * project-name:gitee-extends-toolbox
 * package-name:com.hyts.ext.network.client
 * author:Libo/Alex
 * create-date:2018-10-27 11:45
 * copyright:libo-hyts-github
 * email:libo2dev@aliyun.com
 * description:此类主要用于: BaseClientFactoryBean
 */
public abstract class BaseClientFactoryBean extends ClientFactoryBean<Socket> {


    /**
     * method-name:BaseClientFactoryBean
     * param:Socket
     * return:
     */
    public BaseClientFactoryBean(Socket socket) {
        super(socket);
    }

    /**
     * method-name:BaseClientFactoryBean
     * param:ip port
     * return:
     */
    public BaseClientFactoryBean(String ip, int port) {
        super(ip, port);
        try {
            this.setClient(new Socket(ip,port));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * method-name:
     * param:
     * return:
     */
    public BaseClientFactoryBean() {
        super(DefaultNetwork.DEFAULT_NETWORK_CYCYLE_IP,DefaultNetwork.DEFAULT_NETWORK_LOCAL_PORT);
        try {
            this.setClient(new Socket(this.getIp(),this.getPort()));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

}
